package org.xiji.mediator;

import java.util.Scanner;

/**
 * 中介者模式测试类
 */
public class MediatorMain {

    public static void main(String[] args) {

        //中介者
        Mediator 惜己 = new MediatorImpl();

        //容器
        User 小久 = new User(惜己,"小久");


        //小久父母
        User 父母 = new User(惜己,"小久父母");

        //小久===》父母
        SendAndReceiveContain sendAndReceiveContain = new SendAndReceiveContain(父母, 小久);
        //父母===》小久
        SendAndReceiveContain sendAndReceiveContain1 = new SendAndReceiveContain(小久, 父母);


        Scanner scanner = new Scanner(System.in);
        System.out.println("=====================================");


        while (true) {
            System.out.println("发送东西");
            String msg = scanner.next();
            小久.send(msg,sendAndReceiveContain);
            System.out.println("=====================================");
            System.out.println("父母让惜己帮自己给小久带点东西");
            String msg2 = scanner.next();
            父母.send(msg2,sendAndReceiveContain1);
        }

    }
}
